package com.basker.pisces.core.meta.row;

import java.util.Map;

import com.basker.pisces.core.meta.IDataField;
import com.basker.pisces.core.meta.IField;
import com.basker.pisces.core.meta.ReferenceField;
import com.basker.pisces.core.query.meta.ReferenceFieldDesc;

public class RowReferenceField extends ReferenceField {

    private Map<String/* referenced field alias */, IField /* field in referenceObjectMeta */> referencedFieldMetaMap;

    public RowReferenceField(ReferenceFieldDesc referenceFieldDesc, IDataField refrenceIdField) {
        super(referenceFieldDesc.getAlias(), referenceFieldDesc.getDisplayName(),
                referenceFieldDesc.getReferenceObjectMeta(), refrenceIdField);
        this.referencedFieldMetaMap = referenceFieldDesc.getReferencedFieldMetaMap();
    }

    /**
     * 获取引用的对象元数据中的字段
     *
     * @param name
     * @return
     */
    public IField getReferencedField(String name) {
        return referencedFieldMetaMap.get(name);
    }

}
